package com.jrtc.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jrtc.base.entity.bo.Doctordisease;
import com.jrtc.dao.DoctordiseaseDao;
import com.jrtc.service.DoctordiseaseService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 医生疾病关联表(Doctordisease)表服务实现类
 *
 * @author makejava
 * @since 2022-03-21 17:34:12
 */
@Service("doctordiseaseService")
public class DoctordiseaseServiceImpl implements DoctordiseaseService
{
    @Resource
    private DoctordiseaseDao doctordiseaseDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Doctordisease queryById(Integer id) {
        return this.doctordiseaseDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Doctordisease> queryAllByLimit(int offset, int limit) {
        return this.doctordiseaseDao.queryAllByLimit(offset, limit);
    }

    @Override
    public IPage<Doctordisease> queryDoctordiseaseList(Doctordisease doctordisease)
    {
        com.baomidou.mybatisplus.extension.plugins.pagination.Page<Doctordisease> page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(doctordisease.getPageNo(), doctordisease.getPageSize());
        IPage<Doctordisease> doctordiseasePage = this.doctordiseaseDao.queryDoctordiseaseList(page, doctordisease);
        return doctordiseasePage;
    }
    /**
     * 新增数据
     *
     * @param doctordisease 实例对象
     * @return 实例对象
     */
    @Override
    public Doctordisease insert(Doctordisease doctordisease) {
        this.doctordiseaseDao.insert(doctordisease);
        return doctordisease;
    }

    /**
     * 修改数据
     *
     * @param doctordisease 实例对象
     * @return 实例对象
     */
    @Override
    public Doctordisease update(Doctordisease doctordisease) {
        this.doctordiseaseDao.update(doctordisease);
        return this.queryById(doctordisease.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.doctordiseaseDao.deleteById(id) > 0;
    }
}